﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsUserControl.UIUpdateWrapper
{
    /// <summary></summary>
    public class ToolStripButtonUpdator
    {
        private ToolStrip _ToolStrip; 
        private ToolStripButton _Button;
        private string _Text;
        private bool _Enabled;
        private bool _Visible;
        private Color _BackColor;
        private Image _Img;


        /// <summary></summary>
        public ToolStripButtonUpdator(ToolStrip toolStrip, ToolStripButton btn, 
            Color bkColor, bool enabled, string txt, Image img)
        {
            this._ToolStrip = toolStrip;
            this._Button = btn;
            this._BackColor = bkColor;
            this._Enabled = enabled;
            this._Text = txt;
            this._Img = img;
            this._Visible = true;
            this._ToolStrip.Invoke(new MethodInvoker(this.UpdateButton));
        }
        /// <summary></summary>
        public ToolStripButtonUpdator(ToolStrip toolStrip, ToolStripButton btn,
            Color bkColor, bool enabled, bool visible, string txt, Image img)
        {
            this._ToolStrip = toolStrip;
            this._Button = btn;
            this._BackColor = bkColor;
            this._Enabled = enabled;
            this._Text = txt;
            this._Img = img;
            this._Visible = visible;
            this._ToolStrip.Invoke(new MethodInvoker(this.UpdateButton));
        }

        private void UpdateButton()
        {
            this._Button.BackColor = this._BackColor;
            this._Button.Enabled = this._Enabled;
            this._Button.Text = this._Text;
            this._Button.ToolTipText = this._Text;
            this._Button.Image = this._Img;
            this._Button.Visible = this._Visible;
        }
    }
}
